]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
remoteSearch: Stop using callback to return loaded providers
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 23 Jun 2022 16:17:57 +0000 (18:17 +0200)
committerMarge Bot <marge-bot@gnome.org>
Mon, 1 Aug 2022 18:51:14 +0000 (18:51 +0000)
Provider loading has been synchronous since 2013, so we can
just as well return the results directly instead of passing
them to a callback.

Even if we returned to asynchronous loading in the future,
we wouldn't want to use a callback, but make the function
itself async.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>

js/ui/remoteSearch.js
js/ui/search.js

index 8ebb5505209dcde1f26b2640e10b77bc175f5855..d9eef287f1aca68ddd3a56b7189b8a8425dfd249 100644 (file)
@@ -60,7 +60,13 @@ const SearchProvider2Iface = `
 var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
 var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface);
 
-function loadRemoteSearchProviders(searchSettings, callback) {
+/**
+ * loadRemoteSearchProviders:
+ *
+ * @param {Gio.Settings} searchSettings - search settings
+ * @returns {RemoteSearchProvider[]} - the list of remote providers
+ */
+function loadRemoteSearchProviders(searchSettings) {
     let objectPaths = {};
     let loadedProviders = [];
 
@@ -130,10 +136,8 @@ function loadRemoteSearchProviders(searchSettings, callback) {
         }
     }
 
-    if (searchSettings.get_boolean('disable-external')) {
-        callback([]);
-        return;
-    }
+    if (searchSettings.get_boolean('disable-external'))
+        return [];
 
     FileUtils.collectFromDatadirs('search-providers', false, loadRemoteSearchProvider);
 
@@ -184,7 +188,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
         return idxA - idxB;
     });
 
-    callback(loadedProviders);
+    return loadedProviders;
 }
 
 var RemoteSearchProvider = class {
index 3bfb83f9f7a08ca6f44f6a3230d6c443790b305c..5375e7fc629b04a136550c6b9fbec28b0d2d9178 100644 (file)
@@ -615,9 +615,8 @@ var SearchResultsView = GObject.registerClass({
             this._unregisterProvider(provider);
         });
 
-        RemoteSearch.loadRemoteSearchProviders(this._searchSettings, providers => {
-            providers.forEach(this._registerProvider.bind(this));
-        });
+        const providers = RemoteSearch.loadRemoteSearchProviders(this._searchSettings);
+        providers.forEach(this._registerProvider.bind(this));
     }
 
     _registerProvider(provider) {